<template>
  <div ref="heroAttributeChartContainer" style="width: 100%; height: 300px;"></div>
</template>

<script>
import echarts from 'echarts'
import {
  getHeroAttributeChartOption
} from '@/echart/eChartOption'
export default {
  props: {
    data: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      // ECharts实例
      myChart: null
    }
  },
  mounted() {
    // 初始化ECharts实例，并绘制图表
    this.myChart = this.$echarts.init(this.$refs.heroAttributeChartContainer)
    this.drawChart()
  },
  methods: {
    drawChart() {
      // ECharts配置项
      const option = getHeroAttributeChartOption(this.data)
      this.myChart.setOption(option)
    }
  }
}
</script>
